package com.tester.yaa.exam002.volatileThread;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 * @Aduthor yinanan
 * @ClassName Test
 * @Date 2022/12/11 19:07
 * @Description 执行
 **/
public class Test {

    //定义一个线程安全的list
    volatile List list = Collections.synchronizedList(new LinkedList<>());

    //容器中添加对象
    public void add(Object o) {
        this.list.add(o);
    }

    //定义大小
    public int size() {
        return this.list.size();
    }
    
    /** 
    * 执行
    */ 
    public static void main(String[] args) {
        //启动定义的两个线程
        Thread1 thread = new Thread1();
        thread.thread1.start();
        thread.thread2.start();
    }
}